package kr.hkit.Powerjava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGenerater2 {
	
	private boolean[] lotto;
	private Random rnd;
	private static final int SIZE = 6;
	
	public LottoGenerater2(){
		
		lotto = new boolean[45];
		rnd = new Random();		
	}
	
	public void getLottoNum(int cnt) {
		
		for (int i = 0; i < cnt; i++) {
			getLottoNum();
		}	
	}
	public void initLotto() {
		for (int i = 0; i < lotto.length; i++) {
			lotto[i]=false;
		}
	}
	
	public void getLottoNum() {
		int num = -1;
		initLotto();
		for (int i = 0; i < SIZE; i++) {
			num = rnd.nextInt(45);
			if(lotto[num]){
				i--;
			}else{
				lotto[num]=true;
			}
		}
		prnLottoNum();
		
	}
	public void prnLottoNum() {
		for (int i = 0; i < lotto.length; i++) {
			if(lotto[i]){
				System.out.printf("%3d ",i+1);
			}
		}System.out.println();
	}
	

	
	public static void main(String[] args) {
		LottoGenerater2 lotto = new LottoGenerater2();
		lotto.getLottoNum(10);		
	}
	

}
